<?php

/**
 * This is the model class for table "{{parent}}".
 *
 * The followings are the available columns in table '{{parent}}':
 * @property integer $id
 * @property integer $student_id
 * @property string $father_first_name
 * @property string $father_middle_name
 * @property string $father_last_name
 * @property string $mother_first_name
 * @property string $mother_middle_name
 * @property string $mother_last_name
 * @property integer $parent_type
 * @property string $created_date
 * @property string $updated
 * @property integer $deleted
 */
class Parent extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Parent the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{parent}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('student_id, parent_type', 'required'),
			array('student_id, parent_type, deleted', 'numerical', 'integerOnly'=>true),
			array('father_first_name, father_middle_name, father_last_name, mother_first_name, mother_middle_name, mother_last_name', 'length', 'max'=>100),
			array('created_date, updated', 'safe'),
			array('created_date','default','value'=>new CDbExpression('NOW()'),'setOnEmpty'=>false,'on'=>'insert'),
			array('updated','default','value'=>new CDbExpression('NOW()'),'setOnEmpty'=>false,'on'=>'update'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, student_id, father_first_name, father_middle_name, father_last_name, mother_first_name, mother_middle_name, mother_last_name, parent_type, created_date, updated, deleted', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'student_id' => 'Student',
			'father_first_name' => 'Father First Name',
			'father_middle_name' => 'Father Middle Name',
			'father_last_name' => 'Father Last Name',
			'mother_first_name' => 'Mother First Name',
			'mother_middle_name' => 'Mother Middle Name',
			'mother_last_name' => 'Mother Last Name',
			'parent_type' => 'Parent Type',
			'created_date' => 'Created Date',
			'updated' => 'Updated',
			'deleted' => 'Deleted',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('student_id',$this->student_id);
		$criteria->compare('father_first_name',$this->father_first_name,true);
		$criteria->compare('father_middle_name',$this->father_middle_name,true);
		$criteria->compare('father_last_name',$this->father_last_name,true);
		$criteria->compare('mother_first_name',$this->mother_first_name,true);
		$criteria->compare('mother_middle_name',$this->mother_middle_name,true);
		$criteria->compare('mother_last_name',$this->mother_last_name,true);
		$criteria->compare('parent_type',$this->parent_type);
		$criteria->compare('created_date',$this->created_date,true);
		$criteria->compare('updated',$this->updated,true);
		$criteria->compare('deleted',$this->deleted);

		return new CActiveDataProvider(get_class($this), array(
			'pagination'=>array(
    	   		'pageSize'=> ITEMS_PER_PAGE,
    		),
			'criteria'=>$criteria,
			
		));
	}
}